// === uuAltCSS.cleanup ===
// depend: uuAltCSS
(function() {
var _cleanup; // inner namespace

// uuAltCSS.cleanup - Cleanup CSS
_cleanup = function(css) { // @param String: dirty css
                           // @return String: clean css
  return css.replace(/^\s*<!--|-->\s*$/g, ""). // <!-- ... --> (
    replace(/url\(([^\)]+)\)/gi, function(m, data) { // url(...) -> url("...")
      return 'url("' + data.replace(/^["']|["']$/g, "") + '")'; // trim quote
    }).
    replace(/\\([{};,])/g, function(m, c) {
      return (0x10000 + c.charCodeAt(0)).toString(16).replace(/^1/, "\\\\u");
    }).
    replace(/@[^\{]+\{[^\}]*\}/g, ""). // @font-face @page
    replace(/@[^;]+\s*;/g, "").        // @charset
    replace(/\s*[\r\n]+\s*/g, " ").    // ...\r\n...
    replace(/[\u0000-\u001f]+/g, "").  // \u0009 -> "" (unicode)
    replace(/\\x?[0-3]?[0-9a-f]/gi, "").  // "\x9"  -> "" (hex \x00 ~ \x1f)
                                          // "\9"   -> "" (octet \0 ~ \37)
    trim();
};

// --- initialize ---

// --- export ---
window.uuAltCSS.cleanup = _cleanup;

})(); // uuAltCSS.cleanup scope

